package com.dg.cuckoo.admin.action.basicInformation.permissionSettings;

import com.dg.cuckoo.admin.service.UnitToProService;
import com.dg.cuckoo.admin.service.UnitTypeService;
import com.dg.cuckoo.admin.service.UsertoProjectService;
import com.dg.cuckoo.core.BaseController;
import com.dg.cuckoo.core.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 基本资料-权限设置-建设单位对项目
 */
@RestController
@RequestMapping("/basicInformation/permissionSettings/unitToPro")
public class UnitToPro extends BaseController {

    @Autowired
    private UnitToProService service;
    @Autowired
    private UsertoProjectService usertoProjectService;

    /**
     * 视图显示
     * @return
     */
    @PostMapping("view")
    public JsonResult<String> view(){
        String data = service.view();
        return new JsonResult<>(OK,data);
    }

    /**
     * 点击建设单位二级标签
     */


    /**
     * 项目名称点击显示数据
     */
    @PostMapping("viewByOpen")
    public JsonResult<String> viewByOpen(String name){
        String data = service.viewByOpen(name);
        return new JsonResult<>(OK,data);
    }

    /**
     * 搜索
     */
    @PostMapping("search")
    public JsonResult<List<String>> search(String search){
        List<String> data = usertoProjectService.search(search);
        return new JsonResult<>(OK,data);
    }

    /**
     * 保存
     * @param unit 建设单位
     * @param proName 项目名称list
     * @return
     */
    @PostMapping("save")
    public JsonResult<Void> save(String unit,List<String> proName){
        service.save(unit,proName);
        return new JsonResult<>(OK);
    }

    /**
     * 点击建设单位显示项目
     * @param unit 建设单位
     */
    @PostMapping("openUnitInfo")
    public JsonResult<List<String>> openUnitInfo(String unit){
        List<String> data = service.openUnitInfo(unit);
        return new JsonResult<>(OK,data);
    }

}
